package com.chiry.thread.controller;

import com.chiry.thread.service.ThreadService;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sms")
public class SmsController {
    @Autowired
    ThreadService threadService;
    @RequestMapping("send")
    public String SendMessage(String phone){
        /**
         * 1.生成验证码
         * 2。调用短信平台，发送验证码（放入线程池中）
         * 3。将验证码放入redis中
         */
        int code = RandomUtils.nextInt(100000,999999);
        //调用短信平台发送验证码
        threadService.send(phone, code);
        return "send verify code success";
    }
}
